<?php
/**
 * Created by PhpStorm.
 * User: tri
 * Date: 8/10/2014
 * Time: 12:43 PM
 */
session_start();
error_reporting(1);
require_once('../../class_ajax_request/classAjax.php');
include_once('../../application/functions.php');
include_once('../../application/DataConfig.php');
    //process
    if(isset($_POST)){
        $rel = $_POST['rel'];
        $postId = $_POST['postId'];
        $userId = $_POST['userId'];
        $post_type = $_POST['postanswertype'];
        $postanswerid = $_POST['postanswerid'];
        switch($rel){
            case 'delete':
                deletePost($postId);
                break;
            case 'report':
                reportPost($postId,$userId);
                break;
            case 'redo':
                redoPost($postanswerid,$postId,$post_type);
                break;
        }

    }
    //end process

    //function
    function deletePost($postId){
        $obj = new AjaxRequest();
        $obj->deletePostCus($postId);
        echo 1;
    }
    function reportPost($postId, $userId){
        $obj = new AjaxRequest();
        $re = $obj->reportPostCustom($postId,$userId);
        echo 1;
    }
    function redoPost($postanswerid,$postId, $post_type){
        $obj = new AjaxRequest();
        if($postanswerid != 0){
            $obj->redoPost($postanswerid);
            $post_meta_array = $obj->get_post_meta($postId);
            include('answer.content.php');
        }else{

        }
    }
    //end function
?>

